﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WiiGeeDotNet.events;


namespace WiiGeeDotNet.logic
{
public abstract class ProcessingUnit {

	// Classifier
	protected Classifier m_classifier;
  protected int m_gesturecount;
	
  public delegate void NewGestureDelegate(GestureEvent _event);
  public event NewGestureDelegate NewGesture;

  public delegate void StateChangedDelegate(StateEvent _event);
  public event StateChangedDelegate StateChanged;
	
	public ProcessingUnit() {
		this.m_classifier = new Classifier();
		this.m_gesturecount=0;
	}
	

	protected void FireGestureEvent(int id, String _name, double probability) {
		GestureEvent w = new GestureEvent(id, probability);
    w.Name = _name;
    if (NewGesture != null)
    {
      NewGesture(w);
    }
	}
	
	protected void FireStateEvent(int state) {
		StateEvent w = new StateEvent(this, state);
    if (StateChanged != null)
    {
      StateChanged(w);
    }
	}
	
	public abstract void AccelerationReceived(AccelerationEvent _event);

	public abstract void MotionStartReceived(MotionStartEvent _event);

  public abstract void MotionStopReceived(MotionStopEvent _event);
	
	/**
	 * Resets the complete gesturemodel. After reset no gesture is known
	 * to the system.
	 */
	public void Reset() {
		if(this.m_gesturecount>0) {
			this.m_classifier.Clear();
			Console.WriteLine("### Model reset ###");
		} else {
      Console.WriteLine("There doesn't exist any data to reset.");
		}
	}
	
	public abstract String GetGestureData(int _id);
	
	public abstract int AddGesture(String _data);
	
}
}
